<template>
	<view>
		<button type="primary" @click="onClickLive()">开始直播</button>
	<!-- 	<button type="primary" @click="onClickPush()">推流</button>
		<button type="primary" @click="onClickAudioPush()">音频推流</button>
		<button type="primary" @click="onClickStopAudioPush()">停止音频推流</button> -->
	</view>
</template>

<script>
	import Util from '../../../../common/js/util.js'
	import Http from '../../../../common/js/http.js'
	//LVB插件对象
	var sdkwx = uni.requireNativePlugin('TXMLVB-LiveRoom');
	//推流插件对象
	var pusher = uni.requireNativePlugin('TXMLVB-Pusher');
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {
			/*/配置
			pusher.setConfig({
				enablePureAudioPush:true  //纯音频推流
			});
			
			//事件回调
			pusher.setPushListener(function(res){
				console.log(res);
			});//*/
			// setTimeout(() => {
			// 	this.onClickLive()
			// },300)
		},
		onUnload() {
			//退出登录
			sdkwx.logout();
		
			// this.onClickLive()
		},
		methods: {
			text(){
				Http.sendRequest({
					url: '/api/Memberliveplay/roomList',
					data: {
						
					},
					success: res => {
						console.log(res);
						// if(res.code==0){
						// 	console.log(res);
						// 	// console.log(res.message);
						// }else{
						// 	console.log(res.message);
						// }
					}
				})
			},
			onClickLive() {
				// this.$api.sendRequest({
				// 	url: '/api/Memberliveplay/roomList',
				// 	data: {
						
				// 	},
				// 	success: res => {
				// 		if(res.code==0){
				// 			console.log(res);
				// 			// console.log(res.message);
				// 		}else{
				// 			console.log(res.message);
				// 		}
				// 	}
				// })
				//开始直播
				uni.navigateTo({
					url:'/otherpages/member/lives/index/live_room'
				});
				
			},
			onClickPush() {
				//推流
				uni.navigateTo({
					url:'/otherpages/member/lives/index/pusher?type=0'
				});
			},
			onClickAudioPush() {
				//开始推流
				let pushUrl = "rtmp://75775.livepush.myqcloud.com/live/test678";
				pusher.startPusher(pushUrl, function(res){
					console.log(res);
				});
			},
			onClickStopAudioPush() {
				//停止推流
				pusher.stopPusher(true);
			}
		}
	}
</script>

<style>

</style>
